<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 11. Charset Encoding</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="smarty.for.programmers.html" title="Part III. Smarty For Programmers">
<link rel="prev" href="smarty.for.programmers.html" title="Part III. Smarty For Programmers">
<link rel="next" href="smarty.constants.html" title="Chapter 12. Constants">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Chapter 11. Charset Encoding</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="smarty.for.programmers.html">Prev</a> </td>
<th width="60%" align="center">Part III. Smarty For Programmers</th>
<td width="20%" align="right"> <a accesskey="n" href="smarty.constants.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter" title="Chapter 11. Charset Encoding">
<div class="titlepage"><div><div><h2 class="title">
<a name="charset"></a>Chapter 11. Charset Encoding</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl><dt><span class="sect1"><a href="charset.html#charset.encoding">Charset Encoding</a></span></dt></dl>
</div>
<div class="sect1" title="Charset Encoding">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="charset.encoding"></a>Charset Encoding</h2></div></div></div>
<p>
  There are a variety of encodings for textual data, ISO-8859-1 (Latin1) and UTF-8 being the most popular.
  Unless specified otherwise with the <code class="varname">SMARTY_RESOURCE_CHAR_SET</code> constant, Smarty recognizes
  <code class="literal">UTF-8</code> as the internal charset if <a class="ulink" href="http://php.net/mbstring" target="_top">Multibyte String</a> 
  is available, <code class="literal">ISO-8859-1</code> if not.
 </p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>
  <code class="literal">ISO-8859-1</code> has been PHP's default internal charset since the beginning. 
  Unicode has been evolving since 1991. Since then it has become the one charset to conquer them all, as it is capable of
  encoding most of the known characters even accross different character systems (latin, cyrillic, japanese, …). 
  <code class="literal">UTF-8</code> is unicode's most used encoding, as it allows referencing the thousands of character with the smallest
  size overhead possible.
 </p>
<p>Since unicode and UTF-8 are very wide spread nowadays, their use is strongly encouraged.</p>
</div>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>Smarty's internals and core plugins are truly UTF-8 compatible since Smarty 3.1. To achieve unicode compatibility, 
  the <a class="ulink" href="http://php.net/mbstring" target="_top">Multibyte String</a> PECL is required. Unless your PHP environment offers this
  package, Smarty will not be able to offer full-scale UTF-8 compatibility.
 </p>
</div>
<div class="example">
<a name="id414493"></a><p class="title"><b>Example 11.1. Setting a different Charset Encoding</b></p>
<div class="example-contents"><pre class="programlisting">

// use japanese character encoding
if (function_exists('mb_internal_charset')) {
  mb_internal_charset('EUC-JP');
}
define('SMARTY_RESOURCE_CHAR_SET', 'EUC-JP');
require_once 'libs/Smarty.class.php';
$smarty = new Smarty();
  
 </pre></div>
</div>
<br class="example-break">
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="smarty.for.programmers.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="smarty.for.programmers.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="smarty.constants.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Part III. Smarty For Programmers </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Chapter 12. Constants</td>
</tr>
</table>
</div>
</body>
</html>
